// 当前这个模块：对API进行统一的管理
import requests from "./ajax";
import mockRequests from "./mockAjax";

// 三级联动接口
// /api/product/getBaseCategoryList get 无参数
// 发送请求,axios发送请求返回结果Promise对象
export const reqCategoryList = () => requests({
        url: '/product/getBaseCategoryList',
        method: 'get'
    })
    // 获取banner（Home轮播图接口）
export const reqGetBannerList = () => mockRequests({
        url: '/banner',
        method: 'get'
    })
    // 获取（Floor轮播图接口）
export const reqGetFloorList = () => mockRequests({
        url: '/floor',
        method: 'get'
    })
    // 获取搜索模块的地址 地址为/api/list 请求方式是post
    /* 参数
    {
        "category3Id": "61",
        "categoryName": "手机",
        "keyword": "小米",
        "order": "1:desc",
        "pageNo": 1,
        "pageSize": 10,
        "props": ["1:1700-2799:价格", "2:6.65-6.74英寸:屏幕尺寸"],
        "trademark": "4:小米"
      } */
export const reqGetSearchInfo = (params) => requests({
    url: "/list",
    method: "post",
    data: params
})

// 获取产品详情信息的地址 地址为/api/item/{skuId} 请求方式是get
export const reqGoodsInfo = (skuId) => requests({
    url: `/item/${skuId}`,
    method: "get"
})

// 将产品添加到购物车（获取更新某一产品的个数）
export const reqAddOrUpdataShopcart = ({ skuId, skuNum }) => requests({
    url: `/cart/addToCart/${ skuId }/${ skuNum }`,
    method: "post"
})

// 请求验证码
export const reqCode = (phone) => requests({
    url: `/user/passport/sendCode/${phone}`,
    method: "get"
})

// 注册用户
export const reqUserRegister = (data) => requests({
    url: `/user/passport/register`,
    data,
    method: "post"
})

// 登录，参数phone,password
export const reqUserLogin = (data) => requests({
    url: `/user/passport/login`,
    data,
    method: "post"
})

// 获取用户的信息
export const reqUserInfo = () => requests({
    url: `/user/passport/auth/getUserInfo`,
    method: "get"
})